package com.hdu.point_offer;

import java.lang.reflect.Parameter;
import java.time.temporal.ValueRange;
import java.util.logging.Level;

public class lcr143 {

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    class Solution {
        public boolean isSubStructure(TreeNode A, TreeNode B) {
            if (A == null || B == null) return false;
            return isSame(A, B) || isSubStructure(A.left, B) || isSubStructure(A.right, B);
        }

        boolean isSame(TreeNode A, TreeNode B)
        {
            if (A == null && B == null)
            {
                return true;
            }
            else if (A == null) return false;
            else if (B == null) return true;
            else if (A.val != B.val) return false;
            else return isSame(A.left, B.left) && isSame(A.right, B.right);
        }
    }
}
